//
//  JCClubRankListMenuView.m
//  SquashSpark
//
//  Created by 郭吉成 on 2017/12/5.
//  Copyright © 2017年 Coollang-YF. All rights reserved.
//

#import "JCClubRankListMenuView.h"

@interface JCClubRankListMenuView()

@property (weak, nonatomic) IBOutlet UILabel *titleLabel;

@property (weak, nonatomic) IBOutlet UILabel *sectionLabel_01;
@property (strong, nonatomic) IBOutletCollection(UIButton)NSArray *timeBtns;
@property (weak, nonatomic) IBOutlet UIButton *thisWeekBtn;
@property (weak, nonatomic) IBOutlet UILabel *thisWeekLabel;
@property (weak, nonatomic) IBOutlet UIButton *lastWeekBtn;
@property (weak, nonatomic) IBOutlet UILabel *lastWeekLabel;
@property (weak, nonatomic) IBOutlet UIButton *lastMouthBtn;
@property (weak, nonatomic) IBOutlet UILabel *lastMouthLabel;
@property (weak, nonatomic) IBOutlet UIButton *cumulativeBtn;
@property (weak, nonatomic) IBOutlet UILabel *cumulativeLabel;

@property (weak, nonatomic) IBOutlet UILabel *sectionLabel_02;
@property (strong, nonatomic) IBOutletCollection(UIButton)NSArray *typeBtns;
@property (weak, nonatomic) IBOutlet UIButton *exerciseDurationkBtn;
@property (weak, nonatomic) IBOutlet UILabel *exerciseDurationLabel;
@property (weak, nonatomic) IBOutlet UIButton *battingAverageBtn;
@property (weak, nonatomic) IBOutlet UILabel *battingAverageLabel;
@property (weak, nonatomic) IBOutlet UIButton *shootSpeedBtn;
@property (weak, nonatomic) IBOutlet UILabel *shootSpeedLabel;

@property (weak, nonatomic) IBOutlet UIButton *confirmBtn;

@property (assign, nonatomic) ClubMemberRankTimeType timeType;
@property (assign, nonatomic) ClubMemberRankType rankType;

@end

@implementation JCClubRankListMenuView


// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    [self initCode];
}

- (void)setupInitTimeType:(ClubMemberRankTimeType)timeType rankType:(ClubMemberRankType)rankType{
    _timeType = timeType;
    _rankType = rankType;
}

- (void)initCode{
    self.layer.borderColor = [UIColor yellowColor].CGColor;
    self.layer.borderWidth = 2;
    self.layer.cornerRadius = 3;
    
    _confirmBtn.layer.cornerRadius = 3;
    _confirmBtn.layer.masksToBounds = YES;
    
    for (UIButton *btn in _timeBtns) {
        if (btn.tag == _timeType) {
            btn.selected = YES;
        }else{
            btn.selected = NO;
        }
    }
    for (UIButton *btn in _typeBtns) {
        if (btn.tag == _rankType) {
            btn.selected = YES;
        }else{
            btn.selected = NO;
        }
    }
    
    if (_isSearchPopView) {
        _shootSpeedBtn.hidden =
        _shootSpeedLabel.hidden = YES;
    }else{
        _shootSpeedBtn.hidden =
        _shootSpeedLabel.hidden = NO;
    }
}

- (IBAction)timeBtnAction:(UIButton *)sender{
    for (UIButton *btn in _timeBtns) {
        btn.selected = NO;
    }
    sender.selected = YES;
    _timeType = sender.tag;
}

- (IBAction)typeBtnAction:(UIButton *)sender{
    for (UIButton *btn in _typeBtns) {
        btn.selected = NO;
    }
    sender.selected = YES;
    _rankType = sender.tag;
}

- (IBAction)confirmAction:(UIButton *)sender{
    if (self.dismissHandle) {
        self.dismissHandle(_timeType, _rankType);
    }
}

@end
